package com.bjsxt.exception2;

import java.util.Scanner;

public class TestException5 {

    public static void main(String[] args) {

        //1.输入总分
        System.out.println("请输入总分：");
        Scanner input = new Scanner(System.in);
        int totalScore = input.nextInt();

        //2.输入人数
        System.out.println("请输入人数：");
        int number = input.nextInt();

        //如果人数小于等于0，产生一个异常并抛出
        if (number <= 0) {
            throw new RuntimeException("人数必须大于0：" + number);
        }

        //3.计算平均分并输出
        int averageScore = totalScore / number;
        System.out.println("平均分：" + averageScore);

        System.out.println("计算完毕！");
        System.out.println("程序结束！");

    }
}
